Package MusicLandscape.entities
Class Release
- java.lang.Object
-
- MusicLandscape.entities.Release
-
- Direct Known Subclasses:
Album,MusicVideo
public abstract class Release extends java.lang.ObjectThis class represents a release of a specific artist, like an album or a music video.- Since:
- ExerciseSheet04
- Version:
- 1
- Author:
- Jonas Altrock (ew20b126@technikum-wien.at)
-
-
Field Summary
Fields Modifier and Type Field Description private ArtistartistThe artist that released this release.
A null artist represents an unknown artist.private java.lang.StringtitleThe title of this release.
A null title represents an unknown title.private intyearThe year in which this release was released.
The year cannot be negative, value 0 (zero) representing unknown year.
-
Constructor Summary
Constructors Constructor Description Release()Creates a default release.
A default release has default values for all fields (see there).Release(java.lang.String title, Artist artist, int year)Create a release with a specific title of a specific artist in a specific year.Release(Release r)Creates a copy of a release.
This release is a deep copy of an existing release - the original.
-
Method Summary
All Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description ArtistgetArtist()Get the artist of this release.java.lang.StringgetTitle()Get the title of this release.
If the title is unknown a null String is returned.intgetYear()Get the year in which this release was released.voidsetArtist(Artist artist)Set the artist of this release.
This method accepts null arguments.voidsetTitle(java.lang.String title)Set the title of this release.
This method accepts null Strings.voidsetYear(int year)Set the year of this release.
If the argument is outside the allowed range it is ignored.java.lang.StringtoString()Get a textual representation of this release.abstract inttotalTime()Get the total time of this release.
The implementation of this method is left to concrete subclasses.
-
-
-
Field Detail
-
artist
private Artist artist
The artist that released this release.
A null artist represents an unknown artist. By default, it is the default artist.
-
year
private int year
The year in which this release was released.
The year cannot be negative, value 0 (zero) representing unknown year. By default, the year is 1900.
-
title
private java.lang.String title
The title of this release.
A null title represents an unknown title. The default title is unknown.
-
-
Constructor Detail
-
Release
public Release()
Creates a default release.
A default release has default values for all fields (see there).
-
Release
public Release(Release r)
Creates a copy of a release.
This release is a deep copy of an existing release - the original.- Parameters:
r- the release to be copied
-
Release
public Release(java.lang.String title, Artist artist, int year)Create a release with a specific title of a specific artist in a specific year.- Parameters:
title- the title of the new releaseartist- the artist of the new releaseyear- the year of the new release
-
-
Method Detail
-
getTitle
public java.lang.String getTitle()
Get the title of this release.
If the title is unknown a null String is returned.- Returns:
- the title
-
setTitle
public void setTitle(java.lang.String title)
Set the title of this release.
This method accepts null Strings.- Parameters:
title- the title to set
-
getArtist
public Artist getArtist()
Get the artist of this release.- Returns:
- the artist of this release.
-
setArtist
public void setArtist(Artist artist)
Set the artist of this release.
This method accepts null arguments.- Parameters:
artist- the artist to set.
-
getYear
public int getYear()
Get the year in which this release was released.- Returns:
- the year of this release.
-
setYear
public void setYear(int year)
Set the year of this release.
If the argument is outside the allowed range it is ignored.- Parameters:
year- the year to set.
-
totalTime
public abstract int totalTime()
Get the total time of this release.
The implementation of this method is left to concrete subclasses.- Returns:
- the duration of this release in seconds.
-
toString
public java.lang.String toString()
Get a textual representation of this release.The string representation of a release is "title-artist-year-totaltime" (without quotes and all names substituted with their respective values) unknown field are represented by the string "unknown" (without quotes).
- Overrides:
toStringin classjava.lang.Object- Returns:
- the string representation
-
-